

























1+// Qa Lab provider module implements deterministic QA-only web_search behavior.
2+import {
3+MAX_SEARCH_COUNT,
4+readPositiveIntegerParam,
5+readStringParam,
6+resolveSiteName,
7+wrapWebContent,
8+type WebSearchProviderPlugin,
9+} from "openclaw/plugin-sdk/provider-web-search";
10+11+export const QA_LAB_WEB_SEARCH_PROVIDER_ID = "qa-lab-search";
12+13+const QaLabWebSearchSchema = {
14+type: "object",
15+required: ["query"],
16+properties: {
17+query: {
18+type: "string",
19+description: "Search query string.",
20+},
21+count: {
22+type: "integer",
23+description: "Number of deterministic QA results to return.",
24+minimum: 1,
25+maximum: MAX_SEARCH_COUNT,
26+},
27+},
28+additionalProperties: false,
29+} satisfies Record<string, unknown>;
30+31+function buildQaLabSearchResult(query: string, index: number) {
32+const url = `https://docs.openclaw.ai/qa-lab/search-fixture/${index + 1}`;
33+return {
34+title: wrapWebContent(`QA Lab search fixture result ${index + 1}`, "web_search"),
35+ url,
36+description: wrapWebContent(
37+`Deterministic QA Lab web_search result for query: ${query}`,
38+"web_search",
39+),
40+siteName: resolveSiteName(url) || "docs.openclaw.ai",
41+};
42+}
43+44+export function createQaLabWebSearchProvider(): WebSearchProviderPlugin {
45+return {
46+id: QA_LAB_WEB_SEARCH_PROVIDER_ID,
47+label: "QA Lab Search",
48+hint: "Deterministic QA-only web search fixture",
49+requiresCredential: false,
50+envVars: [],
51+placeholder: "(no key needed)",
52+signupUrl: "https://docs.openclaw.ai/concepts/qa-e2e-automation",
53+docsUrl: "https://docs.openclaw.ai/concepts/qa-e2e-automation",
54+credentialPath: "",
55+inactiveSecretPaths: [],
56+getCredentialValue: () => undefined,
57+setCredentialValue: (searchConfigTarget, value) => {
58+void searchConfigTarget;
59+void value;
60+},
61+createTool: () => ({
62+description:
63+"Search a deterministic QA Lab fixture corpus. This provider is for QA runtime parity only and never calls the public web.",
64+parameters: QaLabWebSearchSchema,
65+execute: async (args) => {
66+const query = readStringParam(args, "query", { required: true });
67+const count =
68+readPositiveIntegerParam(args, "count", {
69+max: MAX_SEARCH_COUNT,
70+message: `count must be an integer from 1 to ${MAX_SEARCH_COUNT}.`,
71+}) ?? 1;
72+return {
73+ query,
74+results: Array.from({ length: count }, (_entry, index) =>
75+buildQaLabSearchResult(query, index),
76+),
77+};
78+},
79+}),
80+};
81+}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。