fix(onboarding): daemon progress + web search setup
This commit is contained in:
@@ -49,6 +49,19 @@ type FinalizeOnboardingOptions = {
|
||||
export async function finalizeOnboardingWizard(options: FinalizeOnboardingOptions) {
|
||||
const { flow, opts, baseConfig, nextConfig, settings, prompter, runtime } = options;
|
||||
|
||||
const withWizardProgress = async <T>(
|
||||
label: string,
|
||||
options: { doneMessage?: string },
|
||||
work: (progress: { update: (message: string) => void }) => Promise<T>,
|
||||
): Promise<T> => {
|
||||
const progress = prompter.progress(label);
|
||||
try {
|
||||
return await work(progress);
|
||||
} finally {
|
||||
progress.stop(options.doneMessage);
|
||||
}
|
||||
};
|
||||
|
||||
const systemdAvailable =
|
||||
process.platform === "linux" ? await isSystemdUserServiceAvailable() : true;
|
||||
if (process.platform === "linux" && !systemdAvailable) {
|
||||
@@ -123,12 +136,26 @@ export async function finalizeOnboardingWizard(options: FinalizeOnboardingOption
|
||||
],
|
||||
})) as "restart" | "reinstall" | "skip";
|
||||
if (action === "restart") {
|
||||
await service.restart({
|
||||
profile: process.env.CLAWDBOT_PROFILE,
|
||||
stdout: process.stdout,
|
||||
});
|
||||
await withWizardProgress(
|
||||
"Gateway daemon",
|
||||
{ doneMessage: "Gateway daemon restarted." },
|
||||
async (progress) => {
|
||||
progress.update("Restarting Gateway daemon…");
|
||||
await service.restart({
|
||||
profile: process.env.CLAWDBOT_PROFILE,
|
||||
stdout: process.stdout,
|
||||
});
|
||||
},
|
||||
);
|
||||
} else if (action === "reinstall") {
|
||||
await service.uninstall({ env: process.env, stdout: process.stdout });
|
||||
await withWizardProgress(
|
||||
"Gateway daemon",
|
||||
{ doneMessage: "Gateway daemon uninstalled." },
|
||||
async (progress) => {
|
||||
progress.update("Uninstalling Gateway daemon…");
|
||||
await service.uninstall({ env: process.env, stdout: process.stdout });
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,37 +165,46 @@ export async function finalizeOnboardingWizard(options: FinalizeOnboardingOption
|
||||
) {
|
||||
const devMode =
|
||||
process.argv[1]?.includes(`${path.sep}src${path.sep}`) && process.argv[1]?.endsWith(".ts");
|
||||
const nodePath = await resolvePreferredNodePath({
|
||||
env: process.env,
|
||||
runtime: daemonRuntime,
|
||||
});
|
||||
const { programArguments, workingDirectory } = await resolveGatewayProgramArguments({
|
||||
port: settings.port,
|
||||
dev: devMode,
|
||||
runtime: daemonRuntime,
|
||||
nodePath,
|
||||
});
|
||||
if (daemonRuntime === "node") {
|
||||
const systemNode = await resolveSystemNodeInfo({ env: process.env });
|
||||
const warning = renderSystemNodeWarning(systemNode, programArguments[0]);
|
||||
if (warning) await prompter.note(warning, "Gateway runtime");
|
||||
}
|
||||
const environment = buildServiceEnvironment({
|
||||
env: process.env,
|
||||
port: settings.port,
|
||||
token: settings.gatewayToken,
|
||||
launchdLabel:
|
||||
process.platform === "darwin"
|
||||
? resolveGatewayLaunchAgentLabel(process.env.CLAWDBOT_PROFILE)
|
||||
: undefined,
|
||||
});
|
||||
await service.install({
|
||||
env: process.env,
|
||||
stdout: process.stdout,
|
||||
programArguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
});
|
||||
await withWizardProgress(
|
||||
"Gateway daemon",
|
||||
{ doneMessage: "Gateway daemon installed." },
|
||||
async (progress) => {
|
||||
progress.update("Preparing Gateway daemon…");
|
||||
const nodePath = await resolvePreferredNodePath({
|
||||
env: process.env,
|
||||
runtime: daemonRuntime,
|
||||
});
|
||||
const { programArguments, workingDirectory } = await resolveGatewayProgramArguments({
|
||||
port: settings.port,
|
||||
dev: devMode,
|
||||
runtime: daemonRuntime,
|
||||
nodePath,
|
||||
});
|
||||
if (daemonRuntime === "node") {
|
||||
const systemNode = await resolveSystemNodeInfo({ env: process.env });
|
||||
const warning = renderSystemNodeWarning(systemNode, programArguments[0]);
|
||||
if (warning) await prompter.note(warning, "Gateway runtime");
|
||||
}
|
||||
const environment = buildServiceEnvironment({
|
||||
env: process.env,
|
||||
port: settings.port,
|
||||
token: settings.gatewayToken,
|
||||
launchdLabel:
|
||||
process.platform === "darwin"
|
||||
? resolveGatewayLaunchAgentLabel(process.env.CLAWDBOT_PROFILE)
|
||||
: undefined,
|
||||
});
|
||||
|
||||
progress.update("Installing Gateway daemon…");
|
||||
await service.install({
|
||||
env: process.env,
|
||||
stdout: process.stdout,
|
||||
programArguments,
|
||||
workingDirectory,
|
||||
environment,
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,16 +389,23 @@ export async function finalizeOnboardingWizard(options: FinalizeOnboardingOption
|
||||
await prompter.note(
|
||||
hasWebSearchKey
|
||||
? [
|
||||
"Web search is ready.",
|
||||
"Web search is enabled, so your agent can look things up online when needed.",
|
||||
"",
|
||||
webSearchKey
|
||||
? "Brave API key: stored in config (tools.web.search.apiKey)."
|
||||
: "Brave API key: provided via BRAVE_API_KEY env var.",
|
||||
? "API key: stored in config (tools.web.search.apiKey)."
|
||||
: "API key: provided via BRAVE_API_KEY env var (Gateway environment).",
|
||||
"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).",
|
||||
"If you want your agent to be able to search the web, you’ll need an API key.",
|
||||
"",
|
||||
"Clawdbot uses Brave Search for the `web_search` tool. Without a Brave Search API key, web search won’t work.",
|
||||
"",
|
||||
"Set it up interactively:",
|
||||
"- Run: clawdbot configure --section web",
|
||||
"- Enable web_search and paste your Brave Search API key",
|
||||
"",
|
||||
"Alternative: set BRAVE_API_KEY in the Gateway environment (no config changes).",
|
||||
"Docs: https://docs.clawd.bot/tools/web",
|
||||
].join("\n"),
|
||||
"Web search (optional)",
|
||||
|
||||
Reference in New Issue
Block a user