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}`, + }); +}