* fix(onboarding): use scoped plugin snapshots to prevent OOM on low-memory hosts Onboarding and channel-add flows previously loaded the full plugin registry, which caused OOM crashes on memory-constrained hosts. This patch introduces scoped, non-activating plugin registry snapshots that load only the selected channel plugin without replacing the running gateway's global state. Key changes: - Add onlyPluginIds and activate options to loadOpenClawPlugins for scoped loads - Add suppressGlobalCommands to plugin registry to avoid leaking commands - Replace full registry reloads in onboarding with per-channel scoped snapshots - Validate command definitions in snapshot loads without writing global registry - Preload configured external plugins via scoped discovery during onboarding Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(test): add return type annotation to hoisted mock to resolve TS2322 * fix(plugins): enforce cache:false invariant for non-activating snapshot loads * Channels: preserve lazy scoped snapshot import after rebase * Onboarding: scope channel snapshots by plugin id * Catalog: trust manifest ids for channel plugin mapping * Onboarding: preserve scoped setup channel loading * Onboarding: restore built-in adapter fallback --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { getChannelPlugin } from "../../channels/plugins/index.js";
|
|
import type { ChannelId, ChannelPlugin, ChannelSetupInput } from "../../channels/plugins/types.js";
|
|
import type { OpenClawConfig } from "../../config/config.js";
|
|
import { normalizeAccountId } from "../../routing/session-key.js";
|
|
|
|
type ChatChannel = ChannelId;
|
|
|
|
export function applyAccountName(params: {
|
|
cfg: OpenClawConfig;
|
|
channel: ChatChannel;
|
|
accountId: string;
|
|
name?: string;
|
|
plugin?: ChannelPlugin;
|
|
}): OpenClawConfig {
|
|
const accountId = normalizeAccountId(params.accountId);
|
|
const plugin = params.plugin ?? getChannelPlugin(params.channel);
|
|
const apply = plugin?.setup?.applyAccountName;
|
|
return apply ? apply({ cfg: params.cfg, accountId, name: params.name }) : params.cfg;
|
|
}
|
|
|
|
export function applyChannelAccountConfig(params: {
|
|
cfg: OpenClawConfig;
|
|
channel: ChatChannel;
|
|
accountId: string;
|
|
input: ChannelSetupInput;
|
|
plugin?: ChannelPlugin;
|
|
}): OpenClawConfig {
|
|
const accountId = normalizeAccountId(params.accountId);
|
|
const plugin = params.plugin ?? getChannelPlugin(params.channel);
|
|
const apply = plugin?.setup?.applyAccountConfig;
|
|
if (!apply) {
|
|
return params.cfg;
|
|
}
|
|
return apply({ cfg: params.cfg, accountId, input: params.input });
|
|
}
|