mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 01:43:15 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
67
openclaw/extensions/xai/web-search.ts
Normal file
67
openclaw/extensions/xai/web-search.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import {
|
||||
createWebSearchProviderContractFields,
|
||||
type WebSearchProviderPlugin,
|
||||
type WebSearchProviderSetupContext,
|
||||
} from "openclaw/plugin-sdk/provider-web-search-config-contract";
|
||||
|
||||
const XAI_CREDENTIAL_PATH = "plugins.entries.xai.config.webSearch.apiKey";
|
||||
type XaiWebSearchProviderRuntime = typeof import("./src/web-search-provider.runtime.js");
|
||||
|
||||
let xaiWebSearchProviderRuntimePromise: Promise<XaiWebSearchProviderRuntime> | undefined;
|
||||
|
||||
function loadXaiWebSearchProviderRuntime(): Promise<XaiWebSearchProviderRuntime> {
|
||||
xaiWebSearchProviderRuntimePromise ??= import("./src/web-search-provider.runtime.js");
|
||||
return xaiWebSearchProviderRuntimePromise;
|
||||
}
|
||||
|
||||
const GenericXaiSearchSchema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
query: { type: "string", description: "Search query string." },
|
||||
count: {
|
||||
type: "number",
|
||||
description: "Number of results to return (1-10).",
|
||||
minimum: 1,
|
||||
maximum: 10,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
} satisfies Record<string, unknown>;
|
||||
|
||||
async function runXaiSearchProviderSetup(
|
||||
ctx: WebSearchProviderSetupContext,
|
||||
): Promise<WebSearchProviderSetupContext["config"]> {
|
||||
const runtime = await loadXaiWebSearchProviderRuntime();
|
||||
return await runtime.runXaiSearchProviderSetup(ctx);
|
||||
}
|
||||
|
||||
export function createXaiWebSearchProvider(): WebSearchProviderPlugin {
|
||||
return {
|
||||
id: "grok",
|
||||
label: "Grok (xAI)",
|
||||
hint: "Requires xAI API key · xAI web-grounded responses",
|
||||
onboardingScopes: ["text-inference"],
|
||||
credentialLabel: "xAI API key",
|
||||
envVars: ["XAI_API_KEY"],
|
||||
placeholder: "xai-...",
|
||||
signupUrl: "https://console.x.ai/",
|
||||
docsUrl: "https://docs.openclaw.ai/tools/web",
|
||||
autoDetectOrder: 30,
|
||||
credentialPath: XAI_CREDENTIAL_PATH,
|
||||
...createWebSearchProviderContractFields({
|
||||
credentialPath: XAI_CREDENTIAL_PATH,
|
||||
searchCredential: { type: "scoped", scopeId: "grok" },
|
||||
configuredCredential: { pluginId: "xai" },
|
||||
}),
|
||||
runSetup: runXaiSearchProviderSetup,
|
||||
createTool: (ctx) => ({
|
||||
description:
|
||||
"Search the web using xAI Grok. Returns AI-synthesized answers with citations from real-time web search.",
|
||||
parameters: GenericXaiSearchSchema,
|
||||
execute: async (args) => {
|
||||
const { executeXaiWebSearchProviderTool } = await loadXaiWebSearchProviderRuntime();
|
||||
return await executeXaiWebSearchProviderTool(ctx, args);
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue