惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园 - Franky
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
小众软件
小众软件
罗磊的独立博客
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
美团技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
C
Check Point Blog
WordPress大学
WordPress大学
博客园 - 【当耐特】
博客园 - 司徒正美
D
Docker

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(channels): centralize route normalization · open...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -1,98 +1,16 @@

11

import { resolveComparableTargetForLoadedChannel } from "../channels/plugins/target-parsing-loaded.js";

2+

import { normalizeOptionalString } from "../shared/string-coerce.js";

23

import {

3-

normalizeOptionalLowercaseString,

4-

normalizeOptionalString,

5-

normalizeOptionalThreadValue,

6-

} from "../shared/string-coerce.js";

4+

deliveryContextFromSession,

5+

mergeDeliveryContext,

6+

normalizeDeliveryContext,

7+

} from "../utils/delivery-context.shared.js";

8+

import type {

9+

DeliveryContext,

10+

DeliveryContextSessionSource,

11+

} from "../utils/delivery-context.types.js";

712

import { isInternalMessageChannel } from "../utils/message-channel.js";

8-9-

export type DeliveryContext = {

10-

channel?: string;

11-

to?: string;

12-

accountId?: string;

13-

threadId?: string | number;

14-

};

15-16-

type DeliveryContextSource = {

17-

channel?: string;

18-

lastChannel?: string;

19-

lastTo?: string;

20-

lastAccountId?: string;

21-

lastThreadId?: string | number;

22-

origin?: {

23-

provider?: string;

24-

accountId?: string;

25-

threadId?: string | number;

26-

};

27-

deliveryContext?: DeliveryContext;

28-

};

29-30-

function normalizeDeliveryContext(context?: DeliveryContext): DeliveryContext | undefined {

31-

if (!context) {

32-

return undefined;

33-

}

34-

const normalized: DeliveryContext = {

35-

channel: normalizeOptionalLowercaseString(context.channel),

36-

to: normalizeOptionalString(context.to),

37-

accountId: normalizeOptionalString(context.accountId),

38-

};

39-

const threadId = normalizeOptionalThreadValue(context.threadId);

40-

if (threadId != null) {

41-

normalized.threadId = threadId;

42-

}

43-

if (

44-

!normalized.channel &&

45-

!normalized.to &&

46-

!normalized.accountId &&

47-

normalized.threadId == null

48-

) {

49-

return undefined;

50-

}

51-

return normalized;

52-

}

53-54-

function mergeDeliveryContext(

55-

primary?: DeliveryContext,

56-

fallback?: DeliveryContext,

57-

): DeliveryContext | undefined {

58-

const normalizedPrimary = normalizeDeliveryContext(primary);

59-

const normalizedFallback = normalizeDeliveryContext(fallback);

60-

if (!normalizedPrimary && !normalizedFallback) {

61-

return undefined;

62-

}

63-

const channelsConflict =

64-

normalizedPrimary?.channel &&

65-

normalizedFallback?.channel &&

66-

normalizedPrimary.channel !== normalizedFallback.channel;

67-

return normalizeDeliveryContext({

68-

channel: normalizedPrimary?.channel ?? normalizedFallback?.channel,

69-

to: channelsConflict

70-

? normalizedPrimary?.to

71-

: (normalizedPrimary?.to ?? normalizedFallback?.to),

72-

accountId: channelsConflict

73-

? normalizedPrimary?.accountId

74-

: (normalizedPrimary?.accountId ?? normalizedFallback?.accountId),

75-

threadId: channelsConflict

76-

? normalizedPrimary?.threadId

77-

: (normalizedPrimary?.threadId ?? normalizedFallback?.threadId),

78-

});

79-

}

80-81-

function deliveryContextFromSession(entry?: DeliveryContextSource): DeliveryContext | undefined {

82-

if (!entry) {

83-

return undefined;

84-

}

85-

return normalizeDeliveryContext({

86-

channel:

87-

entry.deliveryContext?.channel ??

88-

entry.lastChannel ??

89-

entry.channel ??

90-

entry.origin?.provider,

91-

to: entry.deliveryContext?.to ?? entry.lastTo,

92-

accountId: entry.deliveryContext?.accountId ?? entry.lastAccountId ?? entry.origin?.accountId,

93-

threadId: entry.deliveryContext?.threadId ?? entry.lastThreadId ?? entry.origin?.threadId,

94-

});

95-

}

13+

export type { DeliveryContext } from "../utils/delivery-context.types.js";

96149715

function stripThreadRouteSuffix(target: string): string {

9816

return /^(.*):topic:[^:]+$/u.exec(target)?.[1] ?? target;

@@ -103,7 +21,7 @@ function normalizeAnnounceRouteTarget(context?: DeliveryContext): string | undef

10321

if (!rawTo) {

10422

return undefined;

10523

}

106-

const channel = normalizeOptionalLowercaseString(context?.channel);

24+

const channel = normalizeOptionalString(context?.channel);

10725

const parsed = channel

10826

? resolveComparableTargetForLoadedChannel({

10927

channel,

@@ -141,7 +59,7 @@ function shouldStripThreadFromAnnounceEntry(

14159

}

1426014361

export function resolveAnnounceOrigin(

144-

entry?: DeliveryContextSource,

62+

entry?: DeliveryContextSessionSource,

14563

requesterOrigin?: DeliveryContext,

14664

): DeliveryContext | undefined {

14765

const normalizedRequester = normalizeDeliveryContext(requesterOrigin);