mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 15:00:25 +00:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import type { OpenClawConfig } from "../config/config.js";
|
|
import "./test-helpers/fast-core-tools.js";
|
|
import { createOpenClawTools } from "./openclaw-tools.js";
|
|
|
|
async function withTempAgentDir<T>(run: (agentDir: string) => Promise<T>): Promise<T> {
|
|
const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-tools-pdf-"));
|
|
try {
|
|
return await run(agentDir);
|
|
} finally {
|
|
await fs.rm(agentDir, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
describe("createOpenClawTools PDF registration", () => {
|
|
it("includes pdf tool when pdfModel is configured", async () => {
|
|
await withTempAgentDir(async (agentDir) => {
|
|
const cfg: OpenClawConfig = {
|
|
agents: {
|
|
defaults: {
|
|
pdfModel: { primary: "openai/gpt-5.4-mini" },
|
|
},
|
|
},
|
|
};
|
|
|
|
const tools = createOpenClawTools({ config: cfg, agentDir });
|
|
expect(tools.some((tool) => tool.name === "pdf")).toBe(true);
|
|
});
|
|
});
|
|
});
|