Nostr: move outbound session routing behind plugin boundary
This commit is contained in:
parent
b8dd6548aa
commit
de0285d8ea
@ -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: {
|
||||
|
||||
25
extensions/nostr/src/session-route.ts
Normal file
25
extensions/nostr/src/session-route.ts
Normal 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}`,
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user