Nostr: move outbound session routing behind plugin boundary

This commit is contained in:
Gustavo Madeira Santana 2026-03-18 04:03:51 +00:00
parent b8dd6548aa
commit de0285d8ea
No known key found for this signature in database
2 changed files with 27 additions and 0 deletions

View File

@ -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<ResolvedNostrAccount> = {
},
hint: "<npub|hex pubkey|nostr:npub...>",
},
resolveOutboundSessionRoute: (params) => resolveNostrOutboundSessionRoute(params),
},
outbound: {

View File

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