fix(plugins): narrow nested allowFrom account resolver

This commit is contained in:
Vincent Koc
2026-04-04 03:16:02 +09:00
parent 7d691a3ce3
commit 956e746da1

View File

@@ -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,
});
}