mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 02:31:24 +00:00
* refactor(xai): move x_search config behind plugin boundary * chore(changelog): note x_search config migration * fix(xai): include x_search migration helpers
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createXSearchTool } from "./x-search.js";
|
|
|
|
const liveEnabled =
|
|
process.env.OPENCLAW_LIVE_TEST === "1" && (process.env.XAI_API_KEY ?? "").trim().length > 0;
|
|
|
|
const describeLive = liveEnabled ? describe : describe.skip;
|
|
|
|
describeLive("xai x_search live", () => {
|
|
it("queries X through xAI Responses", async () => {
|
|
const tool = createXSearchTool({
|
|
config: {
|
|
plugins: {
|
|
entries: {
|
|
xai: {
|
|
config: {
|
|
xSearch: {
|
|
enabled: true,
|
|
model: "grok-4-1-fast-non-reasoning",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(tool).toBeTruthy();
|
|
const result = await tool!.execute("x-search:live", {
|
|
query: "OpenClaw from:steipete",
|
|
to_date: "2026-03-28",
|
|
});
|
|
|
|
const details = (result.details ?? {}) as {
|
|
provider?: string;
|
|
content?: string;
|
|
citations?: string[];
|
|
inlineCitations?: unknown[];
|
|
error?: string;
|
|
message?: string;
|
|
};
|
|
|
|
expect(details.error, details.message).toBeUndefined();
|
|
expect(details.provider).toBe("xai");
|
|
expect(details.content?.trim().length ?? 0).toBeGreaterThan(0);
|
|
|
|
const citationCount =
|
|
(Array.isArray(details.citations) ? details.citations.length : 0) +
|
|
(Array.isArray(details.inlineCitations) ? details.inlineCitations.length : 0);
|
|
expect(citationCount).toBeGreaterThan(0);
|
|
}, 45_000);
|
|
});
|