mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 05:02:11 +00:00
chore: fix bad merge
This commit is contained in:
parent
1dd45908a3
commit
94353f7696
205 changed files with 19244 additions and 14866 deletions
|
|
@ -1,7 +1,7 @@
|
|||
FROM cloudflare/sandbox:0.7.0
|
||||
|
||||
# Install sandbox-agent
|
||||
RUN curl -fsSL https://releases.rivet.dev/sandbox-agent/latest/install.sh | sh
|
||||
RUN curl -fsSL https://releases.rivet.dev/sandbox-agent/0.2.x/install.sh | sh
|
||||
|
||||
# Pre-install agents
|
||||
RUN sandbox-agent install-agent claude && \
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
@ -31,16 +31,19 @@ console.log(` Written: ${written.path} (${written.bytesWritten} bytes)`);
|
|||
|
||||
// Create a session with the uploaded MCP server as a local command.
|
||||
console.log("Creating session with custom MCP tool...");
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, {
|
||||
const session = await client.createSession({
|
||||
agent: detectAgent(),
|
||||
mcp: {
|
||||
customTools: {
|
||||
type: "local",
|
||||
command: ["node", "/opt/mcp/custom-tools/mcp-server.cjs"],
|
||||
},
|
||||
sessionInit: {
|
||||
cwd: "/root",
|
||||
mcpServers: [{
|
||||
name: "customTools",
|
||||
command: "node",
|
||||
args: ["/opt/mcp/custom-tools/mcp-server.cjs"],
|
||||
env: [],
|
||||
}],
|
||||
},
|
||||
});
|
||||
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...");
|
||||
|
|
@ -12,17 +12,19 @@ const { baseUrl, cleanup } = await startDockerSandbox({
|
|||
|
||||
console.log("Creating session with everything MCP server...");
|
||||
const client = await SandboxAgent.connect({ baseUrl });
|
||||
const sessionId = generateSessionId();
|
||||
await client.createSession(sessionId, {
|
||||
const session = await client.createSession({
|
||||
agent: detectAgent(),
|
||||
mcp: {
|
||||
everything: {
|
||||
type: "local",
|
||||
command: ["mcp-server-everything"],
|
||||
timeoutMs: 10000,
|
||||
},
|
||||
sessionInit: {
|
||||
cwd: "/root",
|
||||
mcpServers: [{
|
||||
name: "everything",
|
||||
command: "mcp-server-everything",
|
||||
args: [],
|
||||
env: [],
|
||||
}],
|
||||
},
|
||||
});
|
||||
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.");
|
||||
|
|
|
|||
9
examples/mock-acp-agent/README.md
Normal file
9
examples/mock-acp-agent/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# @sandbox-agent/mock-acp-agent
|
||||
|
||||
Minimal newline-delimited ACP JSON-RPC mock agent.
|
||||
|
||||
Behavior:
|
||||
- Echoes every inbound message as `mock/echo` notification.
|
||||
- For requests (`method` + `id`), returns `result.echoed` payload.
|
||||
- For `mock/ask_client`, emits an agent-initiated `mock/request` before response.
|
||||
- For responses from client (`id` without `method`), emits `mock/client_response` notification.
|
||||
24
examples/mock-acp-agent/package.json
Normal file
24
examples/mock-acp-agent/package.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "@sandbox-agent/mock-acp-agent",
|
||||
"version": "0.1.0",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"description": "Mock ACP agent for adapter integration testing",
|
||||
"license": "Apache-2.0",
|
||||
"main": "./dist/index.js",
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.build.json",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"start": "node ./dist/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "latest",
|
||||
"typescript": "latest"
|
||||
}
|
||||
}
|
||||
100
examples/mock-acp-agent/src/index.ts
Normal file
100
examples/mock-acp-agent/src/index.ts
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
import { createInterface } from "node:readline";
|
||||
|
||||
interface JsonRpcRequest {
|
||||
jsonrpc?: unknown;
|
||||
id?: unknown;
|
||||
method?: unknown;
|
||||
params?: unknown;
|
||||
result?: unknown;
|
||||
error?: unknown;
|
||||
}
|
||||
|
||||
let outboundRequestSeq = 0;
|
||||
|
||||
function writeMessage(payload: unknown): void {
|
||||
process.stdout.write(`${JSON.stringify(payload)}\n`);
|
||||
}
|
||||
|
||||
function echoNotification(message: unknown): void {
|
||||
writeMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "mock/echo",
|
||||
params: {
|
||||
message,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleMessage(raw: string): void {
|
||||
if (!raw.trim()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let msg: JsonRpcRequest;
|
||||
try {
|
||||
msg = JSON.parse(raw) as JsonRpcRequest;
|
||||
} catch (error) {
|
||||
writeMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "mock/parse_error",
|
||||
params: {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
raw,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
echoNotification(msg);
|
||||
|
||||
const hasMethod = typeof msg.method === "string";
|
||||
const hasId = msg.id !== undefined;
|
||||
|
||||
if (hasMethod && hasId) {
|
||||
if (msg.method === "mock/ask_client") {
|
||||
outboundRequestSeq += 1;
|
||||
writeMessage({
|
||||
jsonrpc: "2.0",
|
||||
id: `agent-req-${outboundRequestSeq}`,
|
||||
method: "mock/request",
|
||||
params: {
|
||||
prompt: "please respond",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
writeMessage({
|
||||
jsonrpc: "2.0",
|
||||
id: msg.id,
|
||||
result: {
|
||||
echoed: msg,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasMethod && hasId) {
|
||||
writeMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "mock/client_response",
|
||||
params: {
|
||||
id: msg.id,
|
||||
result: msg.result ?? null,
|
||||
error: msg.error ?? null,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
crlfDelay: Infinity,
|
||||
});
|
||||
|
||||
rl.on("line", (line) => {
|
||||
handleMessage(line);
|
||||
});
|
||||
|
||||
rl.on("close", () => {
|
||||
process.exit(0);
|
||||
});
|
||||
11
examples/mock-acp-agent/tsconfig.build.json
Normal file
11
examples/mock-acp-agent/tsconfig.build.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"allowImportingTsExtensions": false,
|
||||
"noEmit": false,
|
||||
"declaration": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
17
examples/mock-acp-agent/tsconfig.json
Normal file
17
examples/mock-acp-agent/tsconfig.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "Bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
@ -6,9 +6,11 @@ WORKDIR /build
|
|||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
|
||||
# Copy packages needed for the inspector build chain:
|
||||
# inspector -> sandbox-agent SDK -> cli-shared
|
||||
# inspector -> sandbox-agent SDK -> acp-http-client, cli-shared, persist-indexeddb
|
||||
COPY sdks/typescript/ sdks/typescript/
|
||||
COPY sdks/acp-http-client/ sdks/acp-http-client/
|
||||
COPY sdks/cli-shared/ sdks/cli-shared/
|
||||
COPY sdks/persist-indexeddb/ sdks/persist-indexeddb/
|
||||
COPY frontend/packages/inspector/ frontend/packages/inspector/
|
||||
COPY docs/openapi.json docs/
|
||||
|
||||
|
|
@ -16,6 +18,7 @@ COPY docs/openapi.json docs/
|
|||
# but not needed for the inspector build (avoids install errors).
|
||||
RUN set -e; for dir in \
|
||||
sdks/cli sdks/gigacode \
|
||||
sdks/persist-postgres sdks/persist-sqlite sdks/persist-rivet \
|
||||
resources/agent-schemas resources/vercel-ai-sdk-schemas \
|
||||
scripts/release scripts/sandbox-testing \
|
||||
examples/shared examples/docker examples/e2b examples/vercel \
|
||||
|
|
@ -44,6 +47,7 @@ COPY Cargo.toml Cargo.lock ./
|
|||
COPY server/ ./server/
|
||||
COPY gigacode/ ./gigacode/
|
||||
COPY resources/agent-schemas/artifacts/ ./resources/agent-schemas/artifacts/
|
||||
COPY scripts/agent-configs/ ./scripts/agent-configs/
|
||||
COPY --from=frontend /build/frontend/packages/inspector/dist/ ./frontend/packages/inspector/dist/
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/usr/local/cargo/git \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue