From e011c764a7adbef8f1a8993b5b302437e776f112 Mon Sep 17 00:00:00 2001 From: Vignesh Natarajan Date: Sat, 17 Jan 2026 20:33:31 -0800 Subject: [PATCH] Gate lobster plugin tool in sandboxed contexts --- extensions/lobster/index.ts | 8 +++++- extensions/lobster/src/lobster-tool.test.ts | 27 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/extensions/lobster/index.ts b/extensions/lobster/index.ts index f1c06c554..5f459c939 100644 --- a/extensions/lobster/index.ts +++ b/extensions/lobster/index.ts @@ -3,5 +3,11 @@ import type { ClawdbotPluginApi } from "../../src/plugins/types.js"; import { createLobsterTool } from "./src/lobster-tool.js"; export default function register(api: ClawdbotPluginApi) { - api.registerTool(createLobsterTool(api), { optional: true }); + api.registerTool( + (ctx) => { + if (ctx.sandboxed) return null; + return createLobsterTool(api); + }, + { optional: true }, + ); } diff --git a/extensions/lobster/src/lobster-tool.test.ts b/extensions/lobster/src/lobster-tool.test.ts index 3b1dae859..1c69b3280 100644 --- a/extensions/lobster/src/lobster-tool.test.ts +++ b/extensions/lobster/src/lobster-tool.test.ts @@ -4,7 +4,7 @@ import path from "node:path"; import { describe, expect, it } from "vitest"; -import type { ClawdbotPluginApi } from "../../../src/plugins/types.js"; +import type { ClawdbotPluginApi, ClawdbotPluginToolContext } from "../../../src/plugins/types.js"; import { createLobsterTool } from "./lobster-tool.js"; async function writeFakeLobster(params: { @@ -39,6 +39,20 @@ function fakeApi(): ClawdbotPluginApi { }; } +function fakeCtx(overrides: Partial = {}): ClawdbotPluginToolContext { + return { + config: {} as any, + workspaceDir: "/tmp", + agentDir: "/tmp", + agentId: "main", + sessionKey: "main", + messageChannel: undefined, + agentAccountId: undefined, + sandboxed: false, + ...overrides, + }; +} + describe("lobster plugin tool", () => { it("runs lobster and returns parsed envelope in details", async () => { const fake = await writeFakeLobster({ @@ -84,4 +98,15 @@ describe("lobster plugin tool", () => { }), ).rejects.toThrow(/invalid JSON/); }); + + it("can be gated off in sandboxed contexts", async () => { + const api = fakeApi(); + const factoryTool = (ctx: ClawdbotPluginToolContext) => { + if (ctx.sandboxed) return null; + return createLobsterTool(api); + }; + + expect(factoryTool(fakeCtx({ sandboxed: true }))).toBeNull(); + expect(factoryTool(fakeCtx({ sandboxed: false }))?.name).toBe("lobster"); + }); });