refactor: rename clawdbot to moltbot with legacy compat
This commit is contained in:
@@ -4,10 +4,10 @@ import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { ClawdbotPluginApi, ClawdbotPluginToolContext } from "../../../src/plugins/types.js";
|
||||
import type { MoltbotPluginApi, MoltbotPluginToolContext } from "../../../src/plugins/types.js";
|
||||
import { createLobsterTool } from "./lobster-tool.js";
|
||||
|
||||
async function writeFakeLobsterScript(scriptBody: string, prefix = "clawdbot-lobster-plugin-") {
|
||||
async function writeFakeLobsterScript(scriptBody: string, prefix = "moltbot-lobster-plugin-") {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
||||
const isWindows = process.platform === "win32";
|
||||
|
||||
@@ -33,7 +33,7 @@ async function writeFakeLobster(params: { payload: unknown }) {
|
||||
return await writeFakeLobsterScript(scriptBody);
|
||||
}
|
||||
|
||||
function fakeApi(): ClawdbotPluginApi {
|
||||
function fakeApi(): MoltbotPluginApi {
|
||||
return {
|
||||
id: "lobster",
|
||||
name: "lobster",
|
||||
@@ -52,7 +52,7 @@ function fakeApi(): ClawdbotPluginApi {
|
||||
};
|
||||
}
|
||||
|
||||
function fakeCtx(overrides: Partial<ClawdbotPluginToolContext> = {}): ClawdbotPluginToolContext {
|
||||
function fakeCtx(overrides: Partial<MoltbotPluginToolContext> = {}): MoltbotPluginToolContext {
|
||||
return {
|
||||
config: {} as any,
|
||||
workspaceDir: "/tmp",
|
||||
@@ -89,7 +89,7 @@ describe("lobster plugin tool", () => {
|
||||
`const payload = ${JSON.stringify(payload)};\n` +
|
||||
`console.log("noise before json");\n` +
|
||||
`process.stdout.write(JSON.stringify(payload));\n`,
|
||||
"clawdbot-lobster-plugin-noisy-",
|
||||
"moltbot-lobster-plugin-noisy-",
|
||||
);
|
||||
|
||||
const tool = createLobsterTool(fakeApi());
|
||||
@@ -117,7 +117,7 @@ describe("lobster plugin tool", () => {
|
||||
it("rejects invalid JSON from lobster", async () => {
|
||||
const { binPath } = await writeFakeLobsterScript(
|
||||
`process.stdout.write("nope");\n`,
|
||||
"clawdbot-lobster-plugin-bad-",
|
||||
"moltbot-lobster-plugin-bad-",
|
||||
);
|
||||
|
||||
const tool = createLobsterTool(fakeApi());
|
||||
@@ -132,7 +132,7 @@ describe("lobster plugin tool", () => {
|
||||
|
||||
it("can be gated off in sandboxed contexts", async () => {
|
||||
const api = fakeApi();
|
||||
const factoryTool = (ctx: ClawdbotPluginToolContext) => {
|
||||
const factoryTool = (ctx: MoltbotPluginToolContext) => {
|
||||
if (ctx.sandboxed) return null;
|
||||
return createLobsterTool(api);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Type } from "@sinclair/typebox";
|
||||
import { spawn } from "node:child_process";
|
||||
import path from "node:path";
|
||||
|
||||
import type { ClawdbotPluginApi } from "../../../src/plugins/types.js";
|
||||
import type { MoltbotPluginApi } from "../../../src/plugins/types.js";
|
||||
|
||||
type LobsterEnvelope =
|
||||
| {
|
||||
@@ -168,7 +168,7 @@ function parseEnvelope(stdout: string): LobsterEnvelope {
|
||||
throw new Error("lobster returned invalid JSON envelope");
|
||||
}
|
||||
|
||||
export function createLobsterTool(api: ClawdbotPluginApi) {
|
||||
export function createLobsterTool(api: MoltbotPluginApi) {
|
||||
return {
|
||||
name: "lobster",
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user