diff --git a/bin/lib/onboard.js b/bin/lib/onboard.js index 854748e3399..9fabcfd084a 100644 --- a/bin/lib/onboard.js +++ b/bin/lib/onboard.js @@ -3824,13 +3824,22 @@ async function setupPoliciesWithSelection(sandboxName, options = {}) { const selectedPresets = Array.isArray(options.selectedPresets) ? options.selectedPresets : null; const onSelection = typeof options.onSelection === "function" ? options.onSelection : null; const webSearchConfig = options.webSearchConfig || null; + const enabledChannels = Array.isArray(options.enabledChannels) ? options.enabledChannels : null; step(8, 8, "Policy presets"); const suggestions = ["pypi", "npm"]; - if (getCredential("TELEGRAM_BOT_TOKEN")) suggestions.push("telegram"); - if (getCredential("SLACK_BOT_TOKEN") || process.env.SLACK_BOT_TOKEN) suggestions.push("slack"); - if (getCredential("DISCORD_BOT_TOKEN") || process.env.DISCORD_BOT_TOKEN) + if ((getCredential("TELEGRAM_BOT_TOKEN") || process.env.TELEGRAM_BOT_TOKEN) && (!enabledChannels || enabledChannels.includes("telegram"))) + suggestions.push("telegram"); + if ( + (getCredential("SLACK_BOT_TOKEN") || process.env.SLACK_BOT_TOKEN) && + (!enabledChannels || enabledChannels.includes("slack")) + ) + suggestions.push("slack"); + if ( + (getCredential("DISCORD_BOT_TOKEN") || process.env.DISCORD_BOT_TOKEN) && + (!enabledChannels || enabledChannels.includes("discord")) + ) suggestions.push("discord"); if (webSearchConfig) suggestions.push("brave"); @@ -4379,11 +4388,15 @@ async function onboard(opts = {}) { }); } + let enabledChannels = null; const sandboxReuseState = getSandboxReuseState(sandboxName); const resumeSandbox = resume && session?.steps?.sandbox?.status === "complete" && sandboxReuseState === "ready"; if (resumeSandbox) { skippedStepMessage("sandbox", sandboxName); + enabledChannels = Array.isArray(session?.steps?.sandbox?.enabledChannels) + ? session.steps.sandbox.enabledChannels + : null; } else { if (resume && session?.steps?.sandbox?.status === "complete") { if (sandboxReuseState === "not_ready") { @@ -4398,7 +4411,13 @@ async function onboard(opts = {}) { } } } - const enabledChannels = await setupMessagingChannels(); + enabledChannels = await setupMessagingChannels(); + onboardSession.updateSession((current) => { + if (!current.steps) current.steps = {}; + if (!current.steps.sandbox) current.steps.sandbox = {}; + current.steps.sandbox.enabledChannels = enabledChannels; + return current; + }); startRecordedStep("sandbox", { sandboxName, provider, model }); sandboxName = await createSandbox( @@ -4411,7 +4430,7 @@ async function onboard(opts = {}) { enabledChannels, fromDockerfile, ); - onboardSession.markStepComplete("sandbox", { sandboxName, provider, model, nimContainer }); + onboardSession.markStepComplete("sandbox", { sandboxName, provider, model, nimContainer, enabledChannels }); } const resumeOpenclaw = resume && sandboxName && isOpenclawReady(sandboxName); @@ -4453,6 +4472,7 @@ async function onboard(opts = {}) { ? recordedPolicyPresets : null, webSearchConfig, + enabledChannels, onSelection: (policyPresets) => { onboardSession.updateSession((current) => { current.policyPresets = policyPresets;