Revert "Merge pull request #2607 from code-yeongyu/feat/openclaw-integration"

This reverts commit 8213534e87, reversing
changes made to 84fb1113f1.
This commit is contained in:
YeonGyu-Kim
2026-03-16 21:09:08 +09:00
parent 17244e2c84
commit 239da8b02a
14 changed files with 0 additions and 1010 deletions
-41
View File
@@ -1,41 +0,0 @@
import { describe, it, expect } from "bun:test";
import { resolveGateway } from "../client";
import { type OpenClawConfig } from "../types";
describe("OpenClaw Client", () => {
describe("resolveGateway", () => {
const config: OpenClawConfig = {
enabled: true,
gateways: {
foo: { type: "command", command: "echo foo" },
bar: { type: "http", url: "https://example.com" },
},
hooks: {
"session-start": {
gateway: "foo",
instruction: "start",
enabled: true,
},
"session-end": { gateway: "bar", instruction: "end", enabled: true },
stop: { gateway: "foo", instruction: "stop", enabled: false },
},
};
it("resolves valid mapping", () => {
const result = resolveGateway(config, "session-start");
expect(result).not.toBeNull();
expect(result?.gatewayName).toBe("foo");
expect(result?.instruction).toBe("start");
});
it("returns null for disabled hook", () => {
const result = resolveGateway(config, "stop");
expect(result).toBeNull();
});
it("returns null for unmapped event", () => {
const result = resolveGateway(config, "ask-user-question");
expect(result).toBeNull();
});
});
});
-40
View File
@@ -1,40 +0,0 @@
import { describe, it, expect } from "bun:test";
import { OpenClawConfigSchema } from "../../config/schema/openclaw";
describe("OpenClaw Config Schema", () => {
it("validates correct config", () => {
const raw = {
enabled: true,
gateways: {
foo: { type: "command", command: "echo foo" },
bar: { type: "http", url: "https://example.com" },
},
hooks: {
"session-start": {
gateway: "foo",
instruction: "start",
enabled: true,
},
},
};
const parsed = OpenClawConfigSchema.safeParse(raw);
if (!parsed.success) console.log(parsed.error);
expect(parsed.success).toBe(true);
});
it("fails on invalid event", () => {
const raw = {
enabled: true,
gateways: {},
hooks: {
"invalid-event": {
gateway: "foo",
instruction: "start",
enabled: true,
},
},
};
const parsed = OpenClawConfigSchema.safeParse(raw);
expect(parsed.success).toBe(false);
});
});
-78
View File
@@ -1,78 +0,0 @@
import { describe, it, expect } from "bun:test";
import {
interpolateInstruction,
resolveCommandTimeoutMs,
shellEscapeArg,
validateGatewayUrl,
wakeCommandGateway,
} from "../dispatcher";
import { type OpenClawCommandGatewayConfig } from "../types";
describe("OpenClaw Dispatcher", () => {
describe("validateGatewayUrl", () => {
it("accepts valid https URLs", () => {
expect(validateGatewayUrl("https://example.com")).toBe(true);
});
it("rejects http URLs (remote)", () => {
expect(validateGatewayUrl("http://example.com")).toBe(false);
});
it("accepts http URLs for localhost", () => {
expect(validateGatewayUrl("http://localhost:3000")).toBe(true);
expect(validateGatewayUrl("http://127.0.0.1:8080")).toBe(true);
});
});
describe("interpolateInstruction", () => {
it("interpolates variables correctly", () => {
const result = interpolateInstruction("Hello {{name}}!", { name: "World" });
expect(result).toBe("Hello World!");
});
it("handles missing variables", () => {
const result = interpolateInstruction("Hello {{name}}!", {});
expect(result).toBe("Hello !");
});
});
describe("shellEscapeArg", () => {
it("escapes simple string", () => {
expect(shellEscapeArg("foo")).toBe("'foo'");
});
it("escapes string with single quotes", () => {
expect(shellEscapeArg("it's")).toBe("'it'\\''s'");
});
});
describe("resolveCommandTimeoutMs", () => {
it("uses default timeout", () => {
expect(resolveCommandTimeoutMs(undefined, undefined)).toBe(5000);
});
it("uses provided timeout", () => {
expect(resolveCommandTimeoutMs(1000, undefined)).toBe(1000);
});
it("clamps timeout", () => {
expect(resolveCommandTimeoutMs(10, undefined)).toBe(100);
expect(resolveCommandTimeoutMs(1000000, undefined)).toBe(300000);
});
});
describe("wakeCommandGateway", () => {
it("rejects if disabled via env", async () => {
const oldEnv = process.env.OMX_OPENCLAW_COMMAND;
process.env.OMX_OPENCLAW_COMMAND = "0";
const config: OpenClawCommandGatewayConfig = {
type: "command",
command: "echo hi",
};
const result = await wakeCommandGateway("test", config, {});
expect(result.success).toBe(false);
expect(result.error).toContain("disabled");
process.env.OMX_OPENCLAW_COMMAND = oldEnv;
});
});
});