mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-21 14:11:26 +00:00
fix(plugins): narrow nested allowFrom account resolver
This commit is contained in:
@@ -1362,17 +1362,13 @@ export function createNestedChannelParsedAllowFromPrompt(params: {
|
||||
section: params.section,
|
||||
...(params.enabled ? { enabled: true } : {}),
|
||||
});
|
||||
return createPromptParsedAllowFromForAccount({
|
||||
defaultAccountId:
|
||||
typeof params.defaultAccountId === "function"
|
||||
? params.defaultAccountId
|
||||
: () => params.defaultAccountId,
|
||||
const sharedParams = {
|
||||
...(params.noteTitle ? { noteTitle: params.noteTitle } : {}),
|
||||
...(params.noteLines ? { noteLines: params.noteLines } : {}),
|
||||
message: params.message,
|
||||
placeholder: params.placeholder,
|
||||
parseEntries: params.parseEntries,
|
||||
getExistingAllowFrom: ({ cfg }) =>
|
||||
getExistingAllowFrom: ({ cfg }: { cfg: OpenClawConfig }) =>
|
||||
params.getExistingAllowFrom?.(cfg) ??
|
||||
(
|
||||
(cfg.channels?.[params.channel] as Record<string, unknown> | undefined)?.[params.section] as
|
||||
@@ -1381,7 +1377,21 @@ export function createNestedChannelParsedAllowFromPrompt(params: {
|
||||
)?.allowFrom ??
|
||||
[],
|
||||
...(params.mergeEntries ? { mergeEntries: params.mergeEntries } : {}),
|
||||
applyAllowFrom: ({ cfg, allowFrom }) => setAllowFrom(cfg, allowFrom),
|
||||
applyAllowFrom: ({ cfg, allowFrom }: { cfg: OpenClawConfig; allowFrom: string[] }) =>
|
||||
setAllowFrom(cfg, allowFrom),
|
||||
};
|
||||
|
||||
if (typeof params.defaultAccountId === "function") {
|
||||
return createPromptParsedAllowFromForAccount({
|
||||
defaultAccountId: params.defaultAccountId,
|
||||
...sharedParams,
|
||||
});
|
||||
}
|
||||
|
||||
const defaultAccountId = params.defaultAccountId;
|
||||
return createPromptParsedAllowFromForAccount({
|
||||
defaultAccountId: () => defaultAccountId,
|
||||
...sharedParams,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user