mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 20:35:39 -06:00
2c8ed54ddb
Unset heartbeat.target now resolves "owner": elected heartbeat notifications deliver to the operator's DM resolved from commands.ownerAllowFrom or the channel allowFrom (first concrete entry; wildcards and channel-scoped wildcards excluded; configured owners exhausted across channels before any channel-local fallback). Delivery requires the channel's own classifier to positively prove a direct destination — every bundled messaging plugin now ships an inferTargetChatType contract — and unproven or group-shaped destinations fail closed to the visible no-route state. The first implicitly-routed delivery carries a one-line self-explanation naming the target: "none" opt-out. Explicit target "last" remains as the follow-the-conversation opt-in. Refines the unreleased #121892 default before it ships; refs #121880. Co-authored-by: Ayaan Zaidi <hi@obviy.us> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { smsPlugin } from "./channel.js";
|
|
|
|
describe("SMS outbound session routing", () => {
|
|
it("classifies valid phone numbers as direct", () => {
|
|
expect(smsPlugin.messaging?.inferTargetChatType?.({ to: "+1 (555) 123-4567" })).toBe("direct");
|
|
expect(smsPlugin.messaging?.inferTargetChatType?.({ to: "not-a-phone" })).toBeUndefined();
|
|
});
|
|
|
|
it("uses the canonical inbound phone session", async () => {
|
|
const route = await smsPlugin.messaging?.resolveOutboundSessionRoute?.({
|
|
cfg: { session: { dmScope: "per-channel-peer" } },
|
|
agentId: "main",
|
|
target: "sms:+1 (555) 123-4567",
|
|
});
|
|
|
|
expect(route).toMatchObject({
|
|
sessionKey: "agent:main:sms:direct:+15551234567",
|
|
recipientSessionExact: true,
|
|
peer: { kind: "direct", id: "+15551234567" },
|
|
from: "sms:+15551234567",
|
|
to: "sms:+15551234567",
|
|
});
|
|
});
|
|
|
|
it("rejects invalid phone targets", async () => {
|
|
const route = await smsPlugin.messaging?.resolveOutboundSessionRoute?.({
|
|
cfg: {},
|
|
agentId: "main",
|
|
target: "not-a-phone",
|
|
});
|
|
|
|
expect(route).toBeNull();
|
|
});
|
|
});
|