Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 19 additions & 5 deletions bin/lib/onboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,7 @@ async function createSandbox(
preferredInferenceApi = null,
sandboxNameOverride = null,
webSearchConfig = null,
enabledChannels = null,
) {
step(6, 8, "Creating sandbox");

Expand All @@ -2527,6 +2528,15 @@ async function createSandbox(
const getMessagingToken = (envKey) =>
getCredential(envKey) || normalizeCredentialValue(process.env[envKey]) || null;

// When enabledChannels is provided (from the toggle picker), only include
// channels the user selected. When null (backward compat), include all.
const enabledEnvKeys =
enabledChannels != null
? new Set(
MESSAGING_CHANNELS.filter((c) => enabledChannels.includes(c.name)).map((c) => c.envKey),
)
: null;

const messagingTokenDefs = [
{
name: `${sandboxName}-discord-bridge`,
Expand All @@ -2543,7 +2553,7 @@ async function createSandbox(
envKey: "TELEGRAM_BOT_TOKEN",
token: getMessagingToken("TELEGRAM_BOT_TOKEN"),
},
];
].filter(({ envKey }) => !enabledEnvKeys || enabledEnvKeys.has(envKey));
const hasMessagingTokens = messagingTokenDefs.some(({ token }) => !!token);

// Reconcile local registry state with the live OpenShell gateway state.
Expand Down Expand Up @@ -2646,8 +2656,9 @@ async function createSandbox(
// Each channel with a userIdEnvKey in MESSAGING_CHANNELS may have a
// comma-separated list of IDs (e.g. TELEGRAM_ALLOWED_IDS="123,456").
const messagingAllowedIds = {};
const enabledTokenEnvKeys = new Set(messagingTokenDefs.map(({ envKey }) => envKey));
for (const ch of MESSAGING_CHANNELS) {
if (ch.userIdEnvKey && process.env[ch.userIdEnvKey]) {
if (enabledTokenEnvKeys.has(ch.envKey) && ch.userIdEnvKey && process.env[ch.userIdEnvKey]) {
const ids = process.env[ch.userIdEnvKey]
.split(",")
.map((s) => s.trim())
Expand Down Expand Up @@ -3570,7 +3581,7 @@ async function setupMessagingChannels() {
} else {
note(" [non-interactive] No messaging tokens configured. Skipping.");
}
return;
return found;
}

// Single-keypress toggle selector — pre-select channels that already have tokens.
Expand Down Expand Up @@ -3663,7 +3674,7 @@ async function setupMessagingChannels() {
const selected = Array.from(enabled);
if (selected.length === 0) {
console.log(" Skipping messaging channels.");
return;
return [];
}

// For each selected channel, prompt for token if not already set
Expand Down Expand Up @@ -3706,6 +3717,7 @@ async function setupMessagingChannels() {
}
}
console.log("");
return selected;
}

// ── Step 7: OpenClaw ─────────────────────────────────────────────
Expand Down Expand Up @@ -4448,7 +4460,7 @@ async function onboard(opts = {}) {
}
}
}
await setupMessagingChannels();
const enabledChannels = await setupMessagingChannels();

startRecordedStep("sandbox", { sandboxName, provider, model });
sandboxName = await createSandbox(
Expand All @@ -4458,6 +4470,7 @@ async function onboard(opts = {}) {
preferredInferenceApi,
sandboxName,
webSearchConfig,
enabledChannels,
);
onboardSession.markStepComplete("sandbox", { sandboxName, provider, model, nimContainer });
}
Expand Down Expand Up @@ -4565,6 +4578,7 @@ module.exports = {
startGatewayForRecovery,
runCaptureOpenshell,
setupInference,
setupMessagingChannels,
setupNim,
isInferenceRouteReady,
isOpenclawReady,
Expand Down
Loading
Loading