fix(onboarding): move web search hint to end
This commit is contained in:
@@ -347,6 +347,27 @@ export async function finalizeOnboardingWizard(options: FinalizeOnboardingOption
|
||||
);
|
||||
}
|
||||
|
||||
const webSearchKey = (nextConfig.tools?.web?.search?.apiKey ?? "").trim();
|
||||
const webSearchEnv = (process.env.BRAVE_API_KEY ?? "").trim();
|
||||
const hasWebSearchKey = Boolean(webSearchKey || webSearchEnv);
|
||||
await prompter.note(
|
||||
hasWebSearchKey
|
||||
? [
|
||||
"Web search is ready.",
|
||||
webSearchKey
|
||||
? "Brave API key: stored in config (tools.web.search.apiKey)."
|
||||
: "Brave API key: provided via BRAVE_API_KEY env var.",
|
||||
"Docs: https://docs.clawd.bot/tools/web",
|
||||
].join("\n")
|
||||
: [
|
||||
"Recommended: set up a Brave Search API key for web_search.",
|
||||
"Easiest: clawdbot configure --section web (stores tools.web.search.apiKey).",
|
||||
"Env alternative: BRAVE_API_KEY (gateway environment).",
|
||||
"Docs: https://docs.clawd.bot/tools/web",
|
||||
].join("\n"),
|
||||
"Web search (optional)",
|
||||
);
|
||||
|
||||
await prompter.outro(
|
||||
controlUiOpened
|
||||
? "Onboarding complete. Dashboard opened with your token; keep that tab to control Clawdbot."
|
||||
|
||||
@@ -226,4 +226,55 @@ describe("runOnboardingWizard", () => {
|
||||
|
||||
await fs.rm(workspaceDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("shows the web search hint at the end of onboarding", async () => {
|
||||
const prevBraveKey = process.env.BRAVE_API_KEY;
|
||||
delete process.env.BRAVE_API_KEY;
|
||||
|
||||
try {
|
||||
const note: WizardPrompter["note"] = vi.fn(async () => {});
|
||||
const prompter: WizardPrompter = {
|
||||
intro: vi.fn(async () => {}),
|
||||
outro: vi.fn(async () => {}),
|
||||
note,
|
||||
select: vi.fn(async () => "quickstart"),
|
||||
multiselect: vi.fn(async () => []),
|
||||
text: vi.fn(async () => ""),
|
||||
confirm: vi.fn(async () => false),
|
||||
progress: vi.fn(() => ({ update: vi.fn(), stop: vi.fn() })),
|
||||
};
|
||||
|
||||
const runtime: RuntimeEnv = {
|
||||
log: vi.fn(),
|
||||
error: vi.fn(),
|
||||
exit: vi.fn(),
|
||||
};
|
||||
|
||||
await runOnboardingWizard(
|
||||
{
|
||||
acceptRisk: true,
|
||||
flow: "quickstart",
|
||||
authChoice: "skip",
|
||||
installDaemon: false,
|
||||
skipProviders: true,
|
||||
skipSkills: true,
|
||||
skipHealth: true,
|
||||
skipUi: true,
|
||||
},
|
||||
runtime,
|
||||
prompter,
|
||||
);
|
||||
|
||||
const calls = (note as unknown as { mock: { calls: unknown[][] } }).mock.calls;
|
||||
expect(calls.length).toBeGreaterThan(0);
|
||||
const lastCall = calls[calls.length - 1];
|
||||
expect(lastCall?.[1]).toBe("Web search (optional)");
|
||||
} finally {
|
||||
if (prevBraveKey === undefined) {
|
||||
delete process.env.BRAVE_API_KEY;
|
||||
} else {
|
||||
process.env.BRAVE_API_KEY = prevBraveKey;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,15 +75,6 @@ export async function runOnboardingWizard(
|
||||
) {
|
||||
printWizardHeader(runtime);
|
||||
await prompter.intro("Clawdbot onboarding");
|
||||
await prompter.note(
|
||||
[
|
||||
"Recommended: set up a Brave Search API key for web_search.",
|
||||
"Easiest: clawdbot configure --section web (stores tools.web.search.apiKey).",
|
||||
"Env alternative: BRAVE_API_KEY (gateway environment).",
|
||||
"Docs: https://docs.clawd.bot/tools/web",
|
||||
].join("\n"),
|
||||
"Web search (optional)",
|
||||
);
|
||||
await requireRiskAcknowledgement({ opts, prompter });
|
||||
|
||||
const snapshot = await readConfigFileSnapshot();
|
||||
|
||||
Reference in New Issue
Block a user