From 67a3af7f8dbfddca3889f4eb7eac3a54a4ce31a1 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 8 Apr 2026 00:31:10 +0800 Subject: [PATCH] Tests: fix nostr package boundary drift --- extensions/nostr/src/channel.outbound.test.ts | 4 ++-- extensions/nostr/src/gateway.ts | 24 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/extensions/nostr/src/channel.outbound.test.ts b/extensions/nostr/src/channel.outbound.test.ts index 8fdc07f5fb4..c04efac658e 100644 --- a/extensions/nostr/src/channel.outbound.test.ts +++ b/extensions/nostr/src/channel.outbound.test.ts @@ -64,7 +64,7 @@ describe("nostr outbound cfg threading", () => { )) as { stop: () => void }; const cfg = createCfg(); - await nostrOutboundAdapter.sendText({ + await nostrOutboundAdapter.sendText!({ cfg: cfg as OpenClawConfig, to: "NPUB123", text: "|a|b|", @@ -121,7 +121,7 @@ describe("nostr outbound cfg threading", () => { }, }; - await nostrOutboundAdapter.sendText({ + await nostrOutboundAdapter.sendText!({ cfg: cfg as OpenClawConfig, to: "NPUB123", text: "hello", diff --git a/extensions/nostr/src/gateway.ts b/extensions/nostr/src/gateway.ts index 906cb1fcf28..f13b1b0e7da 100644 --- a/extensions/nostr/src/gateway.ts +++ b/extensions/nostr/src/gateway.ts @@ -1,5 +1,6 @@ import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing"; import { attachChannelToResult } from "openclaw/plugin-sdk/channel-send-result"; +import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { createPreCryptoDirectDmAuthorizer, DEFAULT_ACCOUNT_ID, @@ -9,16 +10,12 @@ import { } from "./channel-api.js"; import type { MetricEvent, MetricsSnapshot } from "./metrics.js"; import { normalizePubkey, startNostrBus, type NostrBusHandle } from "./nostr-bus.js"; -import type { OpenClawConfig } from "./runtime-api.js"; import { getNostrRuntime } from "./runtime.js"; import { resolveDefaultNostrAccountId, type ResolvedNostrAccount } from "./types.js"; type NostrGatewayStart = NonNullable< NonNullable["gateway"]>["startAccount"] >; -type NostrPairingText = NonNullable< - NonNullable["pairing"]>["text"]> ->; type NostrOutbound = NonNullable["outbound"]>; const activeBuses = new Map(); @@ -241,20 +238,27 @@ export const startNostrGatewayAccount: NostrGatewayStart = async (ctx) => { }; }; -export const nostrPairingTextAdapter: Pick< - NostrPairingText, - "idLabel" | "message" | "normalizeAllowEntry" | "notify" -> = { +export const nostrPairingTextAdapter = { idLabel: "nostrPubkey", message: "Your pairing request has been approved!", - normalizeAllowEntry: (entry) => { + normalizeAllowEntry: (entry: string) => { try { return normalizePubkey(entry.trim().replace(/^nostr:/i, "")); } catch { return entry.trim(); } }, - notify: async ({ cfg, id, message, accountId }) => { + notify: async ({ + cfg, + id, + message, + accountId, + }: { + cfg: OpenClawConfig; + id: string; + message: string; + accountId?: string; + }) => { const bus = activeBuses.get(accountId ?? resolveDefaultNostrAccountId(cfg)); if (bus) { await bus.sendDm(id, message);