Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app/api/sandboxes/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ export async function OPTIONS() {
/**
* POST /api/sandboxes
*
* Creates a new ephemeral sandbox environment. Optionally executes a command.
* Sandboxes are isolated Linux microVMs that can be used to evaluate
* account-generated code, run AI agent output safely, or execute reproducible tasks.
* The sandbox will automatically stop after the timeout period.
* Creates a new ephemeral sandbox environment. Sandboxes are isolated Linux
* microVMs used to evaluate account-generated code or run AI agent output
* safely. The sandbox automatically stops after the timeout period.
*
* The OpenClaw `prompt` mode (which offloaded to the `run-sandbox-command`
* task) was retired (recoupable/chat#1813) — async agent work now runs on the
* durable `runAgentWorkflow` via `POST /api/chat/runs`.
*
* Authentication: x-api-key header or Authorization Bearer token required.
*
* Request body:
* - command: string (optional) - The command to execute in the sandbox. If omitted, sandbox is created without running any command.
* - args: string[] (optional) - Arguments to pass to the command
* - cwd: string (optional) - Working directory for command execution
* - account_id: string (optional, org keys only) - UUID of the account to create for
*
Comment on lines 34 to 36

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Inspect sandbox body validation and auth source"
sed -n '1,220p' lib/sandbox/validateSandboxBody.ts
echo
sed -n '1,220p' lib/sandbox/createSandboxPostHandler.ts
echo
rg -n -C2 'account_id|accountId|validateAuthContext|getApiKeyAccountId' lib/sandbox app/api/sandboxes

Repository: recoupable/api

Length of output: 50371


Remove account_id from the POST sandbox contract.
app/api/sandboxes/route.ts:34-36 still documents account_id, and lib/sandbox/validateSandboxBody.ts accepts it and passes it into validateAuthContext(). That makes sandbox ownership caller-controlled instead of deriving the account strictly from auth context. Drop the body field and resolve the account from authentication only.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/api/sandboxes/route.ts` around lines 34 - 36, Remove the POST sandbox
request-body support for account_id in the sandbox contract and validation flow.
Update the documentation in route.ts to no longer mention account_id, and change
validateSandboxBody and validateAuthContext so the account is always derived
from the authenticated context rather than passed from the caller. Make sure the
sandbox creation path only uses auth-derived account identity and no longer
accepts or forwards a body-provided account_id.

Source: Coding guidelines

* Response (200):
* - status: "success"
* - sandboxes: [{ sandboxId, sandboxStatus, timeout, createdAt, runId? }]
* - runId is only included when a command was provided
* - sandboxes: [{ sandboxId, sandboxStatus, timeout, createdAt }]
*
* Error (400/401):
* - status: "error"
Expand Down
22 changes: 7 additions & 15 deletions lib/chat/__tests__/const.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ import { describe, it, expect } from "vitest";
import { SYSTEM_PROMPT } from "../const";

describe("SYSTEM_PROMPT", () => {
describe("release routing", () => {
it("includes release management in prompt_sandbox bullet points", () => {
expect(SYSTEM_PROMPT).toContain(
"**All release management** — creating releases, updating release info, checking release status, adding tracks, DSP pitches, marketing plans",
);
});

it("explicitly warns against using create_knowledge_base for releases", () => {
expect(SYSTEM_PROMPT).toContain(
"Do NOT use create_knowledge_base for release information, track listings, or release plans",
);
});
it("no longer references the retired prompt_sandbox tool (chat#1813)", () => {
expect(SYSTEM_PROMPT).not.toContain("prompt_sandbox");
expect(SYSTEM_PROMPT).not.toContain("Sandbox-First");
});

it("directs release-related tasks to prompt_sandbox", () => {
expect(SYSTEM_PROMPT).toContain("always use prompt_sandbox for anything release-related");
});
it("retains the core agent framing", () => {
expect(SYSTEM_PROMPT).toContain("You are Recoup");
expect(SYSTEM_PROMPT).toContain("# Core Expertise");
});
});
16 changes: 0 additions & 16 deletions lib/chat/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,6 @@ export const SYSTEM_PROMPT = `You are Recoup, a friendly, sharp, and strategic A

---

# Sandbox-First Approach

You have a persistent sandbox environment via the **prompt_sandbox** tool. **This is your primary tool.** Use it for:
- Any task involving files, code, data analysis, or content generation
- Creating and editing documents, reports, spreadsheets, or marketing materials
- Building release plans, campaign briefs, or strategy decks
- Generating visualizations, charts, or formatted outputs
- Any multi-step or complex task that benefits from a working environment
- **All release management** — creating releases, updating release info, checking release status, adding tracks, DSP pitches, marketing plans

**Default to prompt_sandbox unless a different tool is clearly better suited.** Other tools are best for quick, single-purpose lookups or updates (e.g., fetching Spotify data, searching the web, editing an image). When in doubt, use the sandbox.

**IMPORTANT:** Do NOT use create_knowledge_base for release information, track listings, or release plans. The sandbox has a release management skill that maintains structured RELEASE.md documents — always use prompt_sandbox for anything release-related.

---

# Core Expertise

You specialize in artist management, fan analysis, marketing funnels, social media strategy, and platform optimization across Spotify, TikTok, Instagram, YouTube, and more.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe("registerCreateKnowledgeBaseTool", () => {
expect(registeredDescription).toContain("NOT for releases, tracks, marketing plans");
});

it("redirects structured data to prompt_sandbox", () => {
expect(registeredDescription).toContain("use prompt_sandbox for those");
it("no longer references the retired prompt_sandbox tool (chat#1813)", () => {
expect(registeredDescription).not.toContain("prompt_sandbox");
});

it("does not mention adding knowledge base files", () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/mcp/tools/files/registerCreateKnowledgeBaseTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function registerCreateKnowledgeBaseTool(server: McpServer): void {
server.registerTool(
"create_knowledge_base",
{
description: `Saves a plain-text knowledge base entry to the artist's permanent storage on Arweave. Use ONLY for general reference notes, bios, or background context — NOT for releases, tracks, marketing plans, or any structured data (use prompt_sandbox for those).`,
description: `Saves a plain-text knowledge base entry to the artist's permanent storage on Arweave. Use ONLY for general reference notes, bios, or background context — NOT for releases, tracks, marketing plans, or any structured data.`,
inputSchema: createKnowledgeBaseSchema,
},
async (args: CreateKnowledgeBaseArgs) => {
Expand Down
2 changes: 0 additions & 2 deletions lib/mcp/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { registerSendEmailTool } from "./registerSendEmailTool";
import { registerAllArtistTools } from "./artists";
import { registerAllChatsTools } from "./chats";
import { registerAllPulseTools } from "./pulse";
import { registerAllSandboxTools } from "./sandbox";

/**
* Registers all MCP tools on the server.
Expand All @@ -40,7 +39,6 @@ export const registerAllTools = (server: McpServer): void => {
registerAllFlamingoTools(server);
registerAllImageTools(server);
registerAllPulseTools(server);
registerAllSandboxTools(server);
registerAllSearchTools(server);
registerAllSora2Tools(server);
registerAllSpotifyTools(server);
Expand Down
205 changes: 0 additions & 205 deletions lib/mcp/tools/sandbox/__tests__/registerPromptSandboxTool.test.ts

This file was deleted.

11 changes: 0 additions & 11 deletions lib/mcp/tools/sandbox/index.ts

This file was deleted.

Loading
Loading