chore: remove unused plugin helper code

This commit is contained in:
Peter Steinberger
2026-04-29 09:24:46 +01:00
parent 88237faed3
commit 7a32d6a09f
12 changed files with 1 additions and 180 deletions

View File

@@ -2,15 +2,10 @@ import fs from "node:fs";
import os from "node:os";
import { beforeEach, describe, expect, it, vi } from "vitest";
const runExec = vi.hoisted(() => vi.fn());
const resolvePreferredOpenClawTmpDirMock = vi.hoisted(() => vi.fn(() => "/tmp/openclaw"));
const OPENCLAW_TMP_ROOT = "/tmp/openclaw";
const TRASH_SOURCE = `${OPENCLAW_TMP_ROOT}/demo`;
vi.mock("../process/exec.js", () => ({
runExec,
}));
vi.mock("openclaw/plugin-sdk/temp-path", () => ({
resolvePreferredOpenClawTmpDir: resolvePreferredOpenClawTmpDirMock,
}));
@@ -27,7 +22,6 @@ function mockTrashContainer(...suffixes: string[]) {
describe("browser trash", () => {
beforeEach(() => {
vi.restoreAllMocks();
runExec.mockReset();
resolvePreferredOpenClawTmpDirMock.mockReset();
resolvePreferredOpenClawTmpDirMock.mockReturnValue("/tmp/openclaw");
vi.spyOn(Date, "now").mockReturnValue(123);
@@ -51,7 +45,6 @@ describe("browser trash", () => {
await expect(movePathToTrash(TRASH_SOURCE)).resolves.toBe(
"/home/test/.Trash/demo-123-secure/demo",
);
expect(runExec).not.toHaveBeenCalled();
expect(mkdirSync).toHaveBeenCalledWith("/home/test/.Trash", {
recursive: true,
mode: 0o700,

View File

@@ -1 +0,0 @@
export { generateSecureToken } from "../sdk-security-runtime.js";

View File

@@ -1 +0,0 @@
export { runExec } from "../sdk-node-runtime.js";

View File

@@ -9,7 +9,6 @@
"discord-api-types": "^0.38.47",
"https-proxy-agent": "^9.0.0",
"opusscript": "^0.1.1",
"typebox": "1.1.33",
"undici": "8.1.0",
"ws": "^8.20.0"
},

View File

@@ -1,114 +0,0 @@
import { stringEnum } from "openclaw/plugin-sdk/channel-actions";
import { Type } from "typebox";
const discordComponentEmojiSchema = Type.Object({
name: Type.String(),
id: Type.Optional(Type.String()),
animated: Type.Optional(Type.Boolean()),
});
const discordComponentOptionSchema = Type.Object({
label: Type.String(),
value: Type.String(),
description: Type.Optional(Type.String()),
emoji: Type.Optional(discordComponentEmojiSchema),
default: Type.Optional(Type.Boolean()),
});
const discordComponentButtonSchema = Type.Object({
label: Type.String(),
style: Type.Optional(stringEnum(["primary", "secondary", "success", "danger", "link"])),
url: Type.Optional(Type.String()),
emoji: Type.Optional(discordComponentEmojiSchema),
disabled: Type.Optional(Type.Boolean()),
allowedUsers: Type.Optional(
Type.Array(
Type.String({
description: "Discord user ids or names allowed to interact with this button.",
}),
),
),
});
const discordComponentSelectSchema = Type.Object({
type: Type.Optional(stringEnum(["string", "user", "role", "mentionable", "channel"])),
placeholder: Type.Optional(Type.String()),
minValues: Type.Optional(Type.Number()),
maxValues: Type.Optional(Type.Number()),
options: Type.Optional(Type.Array(discordComponentOptionSchema)),
});
const discordComponentBlockSchema = Type.Object({
type: Type.String(),
text: Type.Optional(Type.String()),
texts: Type.Optional(Type.Array(Type.String())),
accessory: Type.Optional(
Type.Object({
type: Type.String(),
url: Type.Optional(Type.String()),
button: Type.Optional(discordComponentButtonSchema),
}),
),
spacing: Type.Optional(stringEnum(["small", "large"])),
divider: Type.Optional(Type.Boolean()),
buttons: Type.Optional(Type.Array(discordComponentButtonSchema)),
select: Type.Optional(discordComponentSelectSchema),
items: Type.Optional(
Type.Array(
Type.Object({
url: Type.String(),
description: Type.Optional(Type.String()),
spoiler: Type.Optional(Type.Boolean()),
}),
),
),
file: Type.Optional(Type.String()),
spoiler: Type.Optional(Type.Boolean()),
});
const discordComponentModalFieldSchema = Type.Object({
type: Type.String(),
name: Type.Optional(Type.String()),
label: Type.String(),
description: Type.Optional(Type.String()),
placeholder: Type.Optional(Type.String()),
required: Type.Optional(Type.Boolean()),
options: Type.Optional(Type.Array(discordComponentOptionSchema)),
minValues: Type.Optional(Type.Number()),
maxValues: Type.Optional(Type.Number()),
minLength: Type.Optional(Type.Number()),
maxLength: Type.Optional(Type.Number()),
style: Type.Optional(stringEnum(["short", "paragraph"])),
});
const discordComponentModalSchema = Type.Object({
title: Type.String(),
triggerLabel: Type.Optional(Type.String()),
triggerStyle: Type.Optional(stringEnum(["primary", "secondary", "success", "danger", "link"])),
fields: Type.Array(discordComponentModalFieldSchema),
});
export function createDiscordMessageToolComponentsSchema() {
return Type.Object(
{
text: Type.Optional(Type.String()),
reusable: Type.Optional(
Type.Boolean({
description: "Allow components to be used multiple times until they expire.",
}),
),
container: Type.Optional(
Type.Object({
accentColor: Type.Optional(Type.String()),
spoiler: Type.Optional(Type.Boolean()),
}),
),
blocks: Type.Optional(Type.Array(discordComponentBlockSchema)),
modal: Type.Optional(discordComponentModalSchema),
},
{
description:
"Discord components v2 payload. Set reusable=true to keep buttons, selects, and forms active until expiry.",
},
);
}

View File

@@ -1,6 +0,0 @@
export function jsonToolResult(data: unknown) {
return {
content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }],
details: data,
};
}

View File

@@ -1,27 +0,0 @@
/**
* AllowFrom normalization — zero external dependency version.
*
* Extracted from channel-config-shared.ts. The original used
* `normalizeStringifiedOptionalString` from plugin-sdk, which is
* just `String(x).trim()` for non-null primitives.
*/
/** Normalize a config entry to a trimmed string (empty string for null/undefined). */
function normalizeEntry(entry: unknown): string {
if (entry === null || entry === undefined) {
return "";
}
if (typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean") {
return String(entry).trim();
}
return "";
}
/** Normalize allowFrom entries: strip `qqbot:` prefix, uppercase. */
export function formatAllowFrom(params: { allowFrom: unknown[] | undefined | null }): string[] {
return (params.allowFrom ?? [])
.map((entry) => normalizeEntry(entry))
.filter((entry): entry is string => entry.length > 0)
.map((entry) => entry.replace(/^qqbot:/i, ""))
.map((entry) => entry.toUpperCase());
}

View File

@@ -1 +0,0 @@
export { fetchRemoteMedia } from "openclaw/plugin-sdk/media-runtime";

View File

@@ -7,8 +7,7 @@
"dependencies": {
"@slack/bolt": "^4.7.1",
"@slack/web-api": "^7.15.1",
"https-proxy-agent": "^9.0.0",
"typebox": "1.1.33"
"https-proxy-agent": "^9.0.0"
},
"devDependencies": {
"@openclaw/plugin-sdk": "workspace:*"

View File

@@ -1,13 +0,0 @@
import { Type } from "typebox";
export function createSlackMessageToolBlocksSchema() {
return Type.Array(
Type.Object(
{},
{
additionalProperties: true,
description: "Slack Block Kit payload blocks (Slack only).",
},
),
);
}

View File

@@ -43,7 +43,6 @@ const bundledPluginIgnoredRuntimeDependencies = [
"linkedom",
"openclaw",
"pdfjs-dist",
"typebox",
] as const;
const config = {

6
pnpm-lock.yaml generated
View File

@@ -522,9 +522,6 @@ importers:
opusscript:
specifier: ^0.1.1
version: 0.1.1
typebox:
specifier: 1.1.33
version: 1.1.33
undici:
specifier: 8.1.0
version: 8.1.0
@@ -1226,9 +1223,6 @@ importers:
https-proxy-agent:
specifier: ^9.0.0
version: 9.0.0
typebox:
specifier: 1.1.33
version: 1.1.33
devDependencies:
'@openclaw/plugin-sdk':
specifier: workspace:*