Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions bin/lib/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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") {
Expand All @@ -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(
Expand All @@ -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);
Expand Down Expand Up @@ -4453,6 +4472,7 @@ async function onboard(opts = {}) {
? recordedPolicyPresets
: null,
webSearchConfig,
enabledChannels,
onSelection: (policyPresets) => {
onboardSession.updateSession((current) => {
current.policyPresets = policyPresets;
Expand Down