mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:30:42 +00:00
refactor: delete unused test helpers
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||
import type { AssistantMessage, ToolResultMessage, UserMessage } from "@mariozechner/pi-ai";
|
||||
import type { AssistantMessage, UserMessage } from "@mariozechner/pi-ai";
|
||||
import { ZERO_USAGE_FIXTURE } from "./usage-fixtures.js";
|
||||
|
||||
export function castAgentMessage(message: unknown): AgentMessage {
|
||||
@@ -34,19 +34,3 @@ export function makeAgentAssistantMessage(
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
export function makeAgentToolResultMessage(
|
||||
overrides: Partial<ToolResultMessage> &
|
||||
Pick<ToolResultMessage, "toolCallId" | "toolName" | "content">,
|
||||
): ToolResultMessage {
|
||||
const { toolCallId, toolName, content, ...rest } = overrides;
|
||||
return {
|
||||
role: "toolResult",
|
||||
toolCallId,
|
||||
toolName,
|
||||
content,
|
||||
isError: false,
|
||||
timestamp: 0,
|
||||
...rest,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { mkdirSync, writeFileSync, type RmOptions } from "node:fs";
|
||||
import { mkdirSync, type RmOptions } from "node:fs";
|
||||
import { mkdir, mkdtemp, rm } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
@@ -44,32 +44,3 @@ export function createPluginSdkTestHarness(options?: { cleanup?: RmOptions }) {
|
||||
createTempDirSync,
|
||||
};
|
||||
}
|
||||
|
||||
export function createBundledPluginPublicSurfaceFixture(params: {
|
||||
createTempDirSync: (prefix: string) => string;
|
||||
marker: string;
|
||||
prefix: string;
|
||||
}) {
|
||||
const rootDir = params.createTempDirSync(params.prefix);
|
||||
mkdirSync(path.join(rootDir, "demo"), { recursive: true });
|
||||
writeFileSync(
|
||||
path.join(rootDir, "demo", "api.js"),
|
||||
`export const marker = ${JSON.stringify(params.marker)};\n`,
|
||||
"utf8",
|
||||
);
|
||||
return rootDir;
|
||||
}
|
||||
|
||||
export function createThrowingBundledPluginPublicSurfaceFixture(params: {
|
||||
createTempDirSync: (prefix: string) => string;
|
||||
prefix: string;
|
||||
}) {
|
||||
const rootDir = params.createTempDirSync(params.prefix);
|
||||
mkdirSync(path.join(rootDir, "bad"), { recursive: true });
|
||||
writeFileSync(
|
||||
path.join(rootDir, "bad", "api.js"),
|
||||
`throw new Error("plugin load failure");\n`,
|
||||
"utf8",
|
||||
);
|
||||
return rootDir;
|
||||
}
|
||||
|
||||
@@ -39,19 +39,6 @@ export async function writeClaudeBundleManifest(params: {
|
||||
return pluginRoot;
|
||||
}
|
||||
|
||||
export async function writeBundleTextFiles(
|
||||
rootDir: string,
|
||||
files: Readonly<Record<string, string>>,
|
||||
) {
|
||||
await Promise.all(
|
||||
Object.entries(files).map(async ([relativePath, contents]) => {
|
||||
const filePath = path.join(rootDir, relativePath);
|
||||
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
||||
await fs.writeFile(filePath, contents, "utf-8");
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function createEnabledPluginEntries(pluginIds: readonly string[]) {
|
||||
return Object.fromEntries(pluginIds.map((pluginId) => [pluginId, { enabled: true }]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user