refactor: dedupe runtime and helper flows

This commit is contained in:
Peter Steinberger
2026-03-02 12:53:19 +00:00
parent 5d3f066bbd
commit b02b94673f
17 changed files with 819 additions and 610 deletions

View File

@@ -142,13 +142,7 @@ export function resolveThreadBindingIdleTimeoutMsForChannel(params: {
channel: string;
accountId?: string;
}): number {
const channel = normalizeChannelId(params.channel);
const accountId = normalizeAccountId(params.accountId);
const { root, account } = resolveChannelThreadBindings({
cfg: params.cfg,
channel,
accountId,
});
const { root, account } = resolveThreadBindingChannelScope(params);
return resolveThreadBindingIdleTimeoutMs({
channelIdleHoursRaw: account?.idleHours ?? root?.idleHours,
sessionIdleHoursRaw: params.cfg.session?.threadBindings?.idleHours,
@@ -160,19 +154,27 @@ export function resolveThreadBindingMaxAgeMsForChannel(params: {
channel: string;
accountId?: string;
}): number {
const channel = normalizeChannelId(params.channel);
const accountId = normalizeAccountId(params.accountId);
const { root, account } = resolveChannelThreadBindings({
cfg: params.cfg,
channel,
accountId,
});
const { root, account } = resolveThreadBindingChannelScope(params);
return resolveThreadBindingMaxAgeMs({
channelMaxAgeHoursRaw: account?.maxAgeHours ?? root?.maxAgeHours,
sessionMaxAgeHoursRaw: params.cfg.session?.threadBindings?.maxAgeHours,
});
}
function resolveThreadBindingChannelScope(params: {
cfg: OpenClawConfig;
channel: string;
accountId?: string;
}) {
const channel = normalizeChannelId(params.channel);
const accountId = normalizeAccountId(params.accountId);
return resolveChannelThreadBindings({
cfg: params.cfg,
channel,
accountId,
});
}
export function formatThreadBindingDisabledError(params: {
channel: string;
accountId: string;