From de0285d8ea220212e460ae61f2861d20e3b0776d Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Wed, 18 Mar 2026 04:03:51 +0000 Subject: [PATCH] Nostr: move outbound session routing behind plugin boundary --- extensions/nostr/src/channel.ts | 2 ++ extensions/nostr/src/session-route.ts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 extensions/nostr/src/session-route.ts diff --git a/extensions/nostr/src/channel.ts b/extensions/nostr/src/channel.ts index b75ad26b0ba..7758e1a18ab 100644 --- a/extensions/nostr/src/channel.ts +++ b/extensions/nostr/src/channel.ts @@ -18,6 +18,7 @@ import type { MetricEvent, MetricsSnapshot } from "./metrics.js"; import { normalizePubkey, startNostrBus, type NostrBusHandle } from "./nostr-bus.js"; import type { ProfilePublishResult } from "./nostr-profile.js"; import { getNostrRuntime } from "./runtime.js"; +import { resolveNostrOutboundSessionRoute } from "./session-route.js"; import { nostrSetupAdapter, nostrSetupWizard } from "./setup-surface.js"; import { listNostrAccountIds, @@ -138,6 +139,7 @@ export const nostrPlugin: ChannelPlugin = { }, hint: "", }, + resolveOutboundSessionRoute: (params) => resolveNostrOutboundSessionRoute(params), }, outbound: { diff --git a/extensions/nostr/src/session-route.ts b/extensions/nostr/src/session-route.ts new file mode 100644 index 00000000000..cbf31e89a56 --- /dev/null +++ b/extensions/nostr/src/session-route.ts @@ -0,0 +1,25 @@ +import { + buildChannelOutboundSessionRoute, + stripChannelTargetPrefix, + type ChannelOutboundSessionRouteParams, +} from "openclaw/plugin-sdk/core"; + +export function resolveNostrOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) { + const target = stripChannelTargetPrefix(params.target, "nostr"); + if (!target) { + return null; + } + return buildChannelOutboundSessionRoute({ + cfg: params.cfg, + agentId: params.agentId, + channel: "nostr", + accountId: params.accountId, + peer: { + kind: "direct", + id: target, + }, + chatType: "direct", + from: `nostr:${target}`, + to: `nostr:${target}`, + }); +}