From a19d4c57032749493111739bd61e8a7b6d184fd3 Mon Sep 17 00:00:00 2001 From: Sweets Sweetman Date: Thu, 19 Feb 2026 19:09:44 -0500 Subject: [PATCH] fix: replace opencode with openclaw in prompt-to-command conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prompt param was being converted to `opencode run ""` which no longer exists after the OpenCode→OpenClaw migration. Updates to use `openclaw agent --agent main --message ""` instead. Also updates MCP tool descriptions to reference OpenClaw. Co-Authored-By: Claude Opus 4.6 --- lib/mcp/tools/sandbox/registerRunSandboxCommandTool.ts | 4 ++-- lib/sandbox/__tests__/processCreateSandbox.test.ts | 6 +++--- lib/sandbox/processCreateSandbox.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/mcp/tools/sandbox/registerRunSandboxCommandTool.ts b/lib/mcp/tools/sandbox/registerRunSandboxCommandTool.ts index 1c13e87..ebb0217 100644 --- a/lib/mcp/tools/sandbox/registerRunSandboxCommandTool.ts +++ b/lib/mcp/tools/sandbox/registerRunSandboxCommandTool.ts @@ -19,7 +19,7 @@ const runSandboxCommandSchema = z.object({ .string() .optional() .describe( - 'A prompt to pass to OpenCode. Runs `opencode run ""` in the sandbox. Cannot be used with command.', + 'A prompt to pass to OpenClaw. Runs `openclaw agent --agent main --message ""` in the sandbox. Cannot be used with command.', ), account_id: z .string() @@ -40,7 +40,7 @@ export function registerRunSandboxCommandTool(server: McpServer): void { "run_sandbox_command", { description: - 'Create a sandbox and run a command or OpenCode prompt in it. Use prompt to run `opencode run ""`. Returns the sandbox ID and a run ID to track progress.', + 'Create a sandbox and run a command or OpenClaw prompt in it. Use prompt to run `openclaw agent --agent main --message ""`. Returns the sandbox ID and a run ID to track progress.', inputSchema: runSandboxCommandSchema, }, async (args, extra: RequestHandlerExtra) => { diff --git a/lib/sandbox/__tests__/processCreateSandbox.test.ts b/lib/sandbox/__tests__/processCreateSandbox.test.ts index 8511ec9..ee280c9 100644 --- a/lib/sandbox/__tests__/processCreateSandbox.test.ts +++ b/lib/sandbox/__tests__/processCreateSandbox.test.ts @@ -181,7 +181,7 @@ describe("processCreateSandbox", () => { }); }); - it("converts prompt to opencode run command", async () => { + it("converts prompt to openclaw agent command", async () => { vi.mocked(selectAccountSnapshots).mockResolvedValue([]); vi.mocked(createSandbox).mockResolvedValue({ sandboxId: "sbx_123", @@ -215,8 +215,8 @@ describe("processCreateSandbox", () => { runId: "run_prompt123", }); expect(triggerRunSandboxCommand).toHaveBeenCalledWith({ - command: "opencode", - args: ["run", "create a hello world index.html"], + command: "openclaw", + args: ["agent", "--agent", "main", "--message", "create a hello world index.html"], cwd: undefined, sandboxId: "sbx_123", accountId: "acc_123", diff --git a/lib/sandbox/processCreateSandbox.ts b/lib/sandbox/processCreateSandbox.ts index b9da0e8..8c37c31 100644 --- a/lib/sandbox/processCreateSandbox.ts +++ b/lib/sandbox/processCreateSandbox.ts @@ -22,9 +22,9 @@ export async function processCreateSandbox( ): Promise { const { accountId, prompt, cwd } = input; - // Convert prompt shortcut to opencode command - const command = prompt ? "opencode" : input.command; - const args = prompt ? ["run", prompt] : input.args; + // Convert prompt shortcut to openclaw agent command + const command = prompt ? "openclaw" : input.command; + const args = prompt ? ["agent", "--agent", "main", "--message", prompt] : input.args; // Get account's most recent snapshot if available const accountSnapshots = await selectAccountSnapshots(accountId);