fix(agents): track normalized message target evidence · openclaw/openclaw@928b593
vincentkoc
·
2026-06-15
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -248,6 +248,32 @@ describe("extractMessagingToolSend", () => {
|
248 | 248 | expect(result?.to).toBe("telegram:123"); |
249 | 249 | }); |
250 | 250 | |
| 251 | +it("accepts channelId alias when earlier target aliases are blank", () => { |
| 252 | +const result = extractMessagingToolSend("message", { |
| 253 | +action: "send", |
| 254 | +channel: "telegram", |
| 255 | +target: " ", |
| 256 | +to: "", |
| 257 | +channelId: "123", |
| 258 | +}); |
| 259 | + |
| 260 | +expect(result?.tool).toBe("message"); |
| 261 | +expect(result?.provider).toBe("telegram"); |
| 262 | +expect(result?.to).toBe("telegram:123"); |
| 263 | +}); |
| 264 | + |
| 265 | +it("prefers canonical target over legacy target aliases", () => { |
| 266 | +const result = extractMessagingToolSend("message", { |
| 267 | +action: "send", |
| 268 | +channel: "telegram", |
| 269 | +target: "123", |
| 270 | +to: "456", |
| 271 | +channelId: "789", |
| 272 | +}); |
| 273 | + |
| 274 | +expect(result?.to).toBe("telegram:123"); |
| 275 | +}); |
| 276 | + |
251 | 277 | it("recognizes attachment-style message tool sends", () => { |
252 | 278 | const upload = extractMessagingToolSend("message", { |
253 | 279 | action: "upload-file", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -633,11 +633,11 @@ export function extractToolErrorMessage(result: unknown): string | undefined {
|
633 | 633 | } |
634 | 634 | |
635 | 635 | function resolveMessageToolTarget(args: Record<string, unknown>): string | undefined { |
636 | | -const toRaw = readStringValue(args.to); |
637 | | -if (toRaw) { |
638 | | -return toRaw; |
639 | | -} |
640 | | -return readStringValue(args.target); |
| 636 | +return ( |
| 637 | + normalizeOptionalString(args.target) ?? |
| 638 | +normalizeOptionalString(args.to) ?? |
| 639 | + normalizeOptionalString(args.channelId) |
| 640 | +); |
641 | 641 | } |
642 | 642 | |
643 | 643 | function resolveMessagingToolThreadEvidence(params: { |
@@ -744,7 +744,7 @@ export function extractMessagingToolSend(
|
744 | 744 | const providerId = providerHint ? normalizeChannelId(providerHint) : null; |
745 | 745 | const provider = providerId ?? normalizeOptionalLowercaseString(providerHint) ?? "message"; |
746 | 746 | const to = normalizeTargetForProvider(provider, toRaw); |
747 | | -const pluginExtractionArgs = readStringValue(args.to) ? args : { ...args, to: toRaw }; |
| 747 | +const pluginExtractionArgs = { ...args, to: toRaw }; |
748 | 748 | const pluginExtracted = providerId |
749 | 749 | ? getChannelPlugin(providerId)?.actions?.extractToolSend?.({ args: pluginExtractionArgs }) |
750 | 750 | : null; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。